<template>
  <div>
    <div class="padding">
      <el-descriptions :title="nowRowData.organizationName" :column="2">
        <el-descriptions-item label="报警时间">
          {{ nowRowData.alarmTime }}
        </el-descriptions-item>
        <el-descriptions-item label="地址">
          {{ nowRowData.areanNames }}
        </el-descriptions-item>
        <el-descriptions-item label="摄像头编号">
          {{ nowRowData.videoNum }}
        </el-descriptions-item>
        <el-descriptions-item label="位置">
          {{ nowRowData.videoLocation }}
        </el-descriptions-item>
      </el-descriptions>
    </div>
    <div class="padding">
      <el-descriptions title="监控画面" :column="1">
        <el-descriptions-item>
          <VideoPlay v-if="nowRowData.videoUri" :src="nowRowData.videoUri" :poster="nowRowData.alarmPic" height="200px"
            style="width: 100%; height: 200px; border-radius: 10px"></VideoPlay>
          <FilePreview v-else :showPreviewSrcList="false" :src="nowRowData.alarmPic"
            :baseStyle="{ width: '100%', height: '200px', borderRadius: '10px' }"></FilePreview>
        </el-descriptions-item>
      </el-descriptions>
    </div>

    <el-descriptions title="处理信息" :column="2" v-if="detail">
      <el-descriptions-item label="处理内容">
        {{ nowRowData.handleContent }}
      </el-descriptions-item>
      <el-descriptions-item label="处理时间">
        {{ nowRowData.handleTime }}
      </el-descriptions-item>
    </el-descriptions>

    <AplidForm ref="formRef" v-else v-bind="spotCheckForm" v-model="formModel" @submit="onSubmit" @reset="onReset">
    </AplidForm>
  </div>
</template>

<script setup lang="ts">
import { spotCheckForm } from '../config'
import apiMod from '@/apiMod/index'
import { ElMessage } from 'element-plus'
import { getAreaObj } from '@/utils/util'
import { useDateFormat } from '@vueuse/core'
import VideoPlay from '@/views/aplid/DetailPage/ContentListItem/FileList/videoPlay/index.vue'

const props = withDefaults(defineProps<{ nowRowData: any; detail?: boolean }>(), {})

const emit = defineEmits(['refresh'])

const formModel = ref(props.nowRowData)

const onReset = () => {
  emit('refresh')
}
const formatted = useDateFormat(new Date(), 'YYYY-MM-DD HH:mm:ss')
const onSubmit = (form, done) => {
  const query = {
    ...props.nowRowData,
    ...form,
    handleStatus: 1,
    handleTime: formatted.value,
  }
  apiMod.view_pbVideoAlarm_edit(query).then(() => {
    ElMessage.success('操作成功')
    onReset()
    done()
  })
}

onMounted(() => {
  const areas:any  =  getAreaObj(props.nowRowData, '', 'get')
  formModel.value.areanNames = areas.names
})
</script>

<style scoped></style>
